<div class="layui-form seller-form" action="">
	<div class="layui-form-item">
		<div class="layui-inline">
			<button type="button" class="layui-btn layui-btn-sm add"><i class="layui-icon">&#xe608;</i> 添加
			</button>
		</div>
	</div>
</div>
<div class="table-body">
	<table id="indexTable" lay-filter="indexTable"></table>
</div>
<script>
	layui.use(['table', 'form', 'layer', 'laydate'], function () {
		var layer = layui.layer, table = layui.table, form = layui.form, date = layui.laydate;
		//执行渲染
		table.render({
			elem: '#indexTable', //指定原始表格元素选择器（推荐id选择器）
			height: 'full-139',
			cellMinWidth: '80',
			page: 'true',
			limit: '20',
			id: 'indexTable',
			url: "{:url('index/nav')}",
			cols: [[ //标题栏
				{field: 'id', width: 90, title: 'ID', align: 'center'},
				{field: 'title', title: '名称', align: 'center'},
				{field: 'status', title: '状态', align: 'center'},
				{width: 140, title: '操作', align: 'center', toolbar: '#indexBar'}
			]] //设置表头
			//,…… //更多参数参考右侧目录：基本参数选项
		});
		$(document).on('click', '.add', function () {
			window.location.href = "{:url('index/add')}";
		});
		//监听工具条
		table.on('tool(indexTable)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
			var data = obj.data; //获得当前行数据
			var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
			var tr = obj.tr; //获得当前行 tr 的DOM对象
			if (layEvent === 'edit') { //编辑
				var str = "{:url('index/edit',array('id'=>'a_id'))}";
				editUrl = str.replace('a_id', data.id);
				window.location.href = editUrl;
			}
		});
	})
</script>
<script type="text/html" id="indexBar">
	<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
